
const Controller = require('../core/base_controller');
class BlogController extends Controller {
    async getBlog() {
        const { ctx, app } = this;
        try {
            const res = await ctx.service.blog.getBlog()
            this.success(res)
        } catch (err) {
            this.error(err.message)
        }
    }
    async addBlog() {
        const { ctx, app } = this;
        try {
            const res = await ctx.service.blog.addBlog()
            this.success(res)
        } catch (err) {
            this.error(err.message)
        }
    }
    async like() {
        const { ctx, app } = this;
        try {
            const res = await ctx.service.blog.like()
            this.success(res)
        } catch (err) {
            this.error(err.message)
        }
    }
    async getDetail() {
        const { ctx, app } = this;
        try {
            const res = await ctx.service.blog.getDetail()
            this.success(res)
        } catch (err) {
            this.error(err.message)
        }
    }
    async comment() {
        const { ctx, app } = this;
        try {
            const res = await ctx.service.blog.comment()
            this.success(res)
        } catch (err) {
            this.error(err.message)
        }
    }
    async getComments() {
        const { ctx, app } = this;
        try {
            const res = await ctx.service.blog.getComments()
            this.success(res)
        } catch (err) {
            this.error(err.message)
        }
    }


}

module.exports = BlogController;




// uniapp 多端开发
// 微服务 微前端
// 中台
// 低代码  零代码


// const { ctx, app } = this;
//         const mock = require('mockjs')
//         const { list } = mock.mock({
//             "list|100": [{
//                 title: "@ctitle(5,10)",
//                 content: "@ctitle(50,100)",
//                 author: "@cname",
//                 "type|1": [1, 2, 3, 4, 5, 6, 7],
//                 create_time: Date.now(),
//                 "likes|1-1000": 1,
//                 "looks|1-1000": 1,
//                 "comments|1-1000": 1,
//                 image: "@image(100x100,@color)"
//             }]
//         })
//         list.forEach(item => {
//             app.mysql.insert('blogs', { ...item })
//         })
//         ctx.body = '123'